package csu.web.credit_bank.service.impl;

import csu.web.credit_bank.mapper.AdminMapper;
import csu.web.credit_bank.pojo.Admin;
import csu.web.credit_bank.service.AdminService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {

    @Override
    public Admin createAdmin(Admin admin) {
        // Admin的userId来自于已存在的User, 不通过ID池生成
        this.save(admin);
        return admin;
    }

    @Override
    public Admin getAdminById(String userId) {
        return this.getById(userId);
    }

    @Override
    public Admin updateAdmin(Admin admin) {
        this.updateById(admin);
        return this.getById(admin.getUserId());
    }

    @Override
    public boolean deleteAdmin(String userId) {
        return this.removeById(userId);
    }
}
